﻿#include "PopMktCombineExch.h"

PopMktCombineExch::PopMktCombineExch(QWidget *parent) :
    QWidget(parent)
{
    setupModel();
    setupViews();
}

void PopMktCombineExch::setupModel()
{
    modelPopMktCombineExch = new QStandardItemModel(0, 11, this);
    modelPopMktCombineExch->setHeaderData(0, Qt::Horizontal, QStringLiteral("组合代码"));
    modelPopMktCombineExch->setHeaderData(1, Qt::Horizontal, QStringLiteral("买量"));
    modelPopMktCombineExch->setHeaderData(2, Qt::Horizontal, QStringLiteral("买价"));
    modelPopMktCombineExch->setHeaderData(3, Qt::Horizontal, QStringLiteral("卖价"));
    modelPopMktCombineExch->setHeaderData(4, Qt::Horizontal, QStringLiteral("卖量"));
    modelPopMktCombineExch->setHeaderData(5, Qt::Horizontal, QStringLiteral("最高"));
    modelPopMktCombineExch->setHeaderData(6, Qt::Horizontal, QStringLiteral("最低"));
    modelPopMktCombineExch->setHeaderData(7, Qt::Horizontal, QStringLiteral("涨停板"));
    modelPopMktCombineExch->setHeaderData(8, Qt::Horizontal, QStringLiteral("跌停板"));
    modelPopMktCombineExch->setHeaderData(9, Qt::Horizontal, QStringLiteral("全部买量"));
    modelPopMktCombineExch->setHeaderData(10, Qt::Horizontal, QStringLiteral("全部卖量"));
}

void PopMktCombineExch::setupViews()
{
    MainLayout = new QGridLayout(this);

    tablePopMktCombineExch = new QTableView;
    tablePopMktCombineExch->setAlternatingRowColors(true);
    QFont font = tablePopMktCombineExch->horizontalHeader()->font();
    font.setBold(true);
    tablePopMktCombineExch->horizontalHeader()->setFont(font);
   // tablePopMktCombineExch->setStyleSheet("QTableView::item:selected { selection-color: rgb(0, 0, 0) }" "QTableView::item:selected { background-color: rgb(255, 255, 0) }"
//                "QTableView{background-color: rgb(0, 0, 0);" "alternate-background-color: rgb(41, 36, 33);}");

    tablePopMktCombineExch->setModel(modelPopMktCombineExch);
    tablePopMktCombineExch->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tablePopMktCombineExch->verticalHeader()->setVisible(false); //隐藏列表头
    tablePopMktCombineExch->verticalHeader()->setFixedWidth(40);
    tablePopMktCombineExch->setSelectionBehavior(QAbstractItemView::SelectRows);
    tablePopMktCombineExch->setSelectionMode(QAbstractItemView::SingleSelection);

    tablePopMktCombineExch->setColumnWidth(0, 100);
    tablePopMktCombineExch->setColumnWidth(1, 120);
    tablePopMktCombineExch->setColumnWidth(2, 160);
    tablePopMktCombineExch->setColumnWidth(3, 120);
    tablePopMktCombineExch->setColumnWidth(4, 50);
    tablePopMktCombineExch->setColumnWidth(5, 70);
    tablePopMktCombineExch->setColumnWidth(6, 50);
    tablePopMktCombineExch->setColumnWidth(7, 150);
    tablePopMktCombineExch->setColumnWidth(8, 100);
    tablePopMktCombineExch->setColumnWidth(9, 85);
    tablePopMktCombineExch->setColumnWidth(10, 50);

    MainLayout->addWidget(tablePopMktCombineExch,0,0);
    MainLayout->setMargin(20);
}
